<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="theme-color" content="#33474d">
	<title>Linux 命令- more | 失落的乐章</title>
	<link rel="stylesheet" href="/css/style.css" />
	
      <link rel="alternate" href="/atom.xml" title="失落的乐章" type="application/atom+xml">
    
</head>

<body>

	<header class="header">
		<nav class="header__nav">
			
				<a href="/archives" class="header__link">Archive</a>
			
				<a href="/tags" class="header__link">Tags</a>
			
				<a href="/atom.xml" class="header__link">RSS</a>
			
		</nav>
		<h1 class="header__title"><a href="/">失落的乐章</a></h1>
		<h2 class="header__subtitle">技术面前，永远都是学生。</h2>
	</header>

	<main>
		<article>
	
		<h1>Linux 命令- more</h1>
	
	<div class="article__infos">
		<span class="article__date">2017-10-12</span><br />
		
		
			<span class="article__tags">
			  	<a class="article__tag-link" href="/tags/Linux命令/">Linux命令</a>
			</span>
		
	</div>

	

	
		<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;more命令，功能类似 cat ，cat命令是整个文件的内容从上到下显示在屏幕上。 more会以一页一页的显示方便使用者逐页阅读，而最基本的指令就是按空白键（space）就往下一页显示，按 b 键就会往回（back）一页显示，而且还有搜寻字串的功能 。more命令从前向后读取文件，因此在启动时就加载整个文件。</p>
<h2 id="1．命令格式"><a href="#1．命令格式" class="headerlink" title="1．命令格式"></a>1．命令格式</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">more [-dlfpcsu ] [-num ] [+/ pattern] [+ linenum] [file ... ]</div></pre></td></tr></table></figure>
<h2 id="2．命令功能"><a href="#2．命令功能" class="headerlink" title="2．命令功能"></a>2．命令功能</h2><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;more命令和cat的功能一样都是查看文件里的内容，但有所不同的是more可以按页来查看文件的内容，还支持直接跳转行等功能。</p>
<h2 id="3．命令参数"><a href="#3．命令参数" class="headerlink" title="3．命令参数"></a>3．命令参数</h2><ul>
<li>+n 从笫n行开始显示</li>
<li>定义屏幕大小为n行</li>
<li>+/pattern 在每个档案显示前搜寻该字串（pattern），然后从该字串前两行之后开始显示  </li>
<li>-c 从顶部清屏，然后显示</li>
<li>-d 提示“Press space to continue，’q’ to quit（按空格键继续，按q键退出）”，禁用响铃功能</li>
<li>-l 忽略Ctrl+l（换页）字符</li>
<li>-p 通过清除窗口而不是滚屏来对文件进行换页，与-c选项相似</li>
<li>-s 把连续的多个空行显示为一行</li>
<li>-u 把文件内容中的下画线去掉</li>
</ul>
<h2 id="4．常用操作命令："><a href="#4．常用操作命令：" class="headerlink" title="4．常用操作命令："></a>4．常用操作命令：</h2><ul>
<li>Enter 向下n行，需要定义。默认为1行</li>
<li>Ctrl+F 向下滚动一屏</li>
<li>空格键 向下滚动一屏</li>
<li>Ctrl+B 返回上一屏</li>
<li>=  输出当前行的行号</li>
<li>：f 输出文件名和当前行的行号</li>
<li>V  调用vi编辑器</li>
<li>!命令 调用Shell，并执行命令 </li>
<li>q  退出more</li>
</ul>
<h2 id="5．命令实例："><a href="#5．命令实例：" class="headerlink" title="5．命令实例："></a>5．命令实例：</h2><h3 id="实例1：显示文件中从第3行起的内容"><a href="#实例1：显示文件中从第3行起的内容" class="headerlink" title="实例1：显示文件中从第3行起的内容"></a>实例1：显示文件中从第3行起的内容</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">more +3 log2012.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># cat log2012.log </span></div><div class="line">2012-01</div><div class="line">2012-02</div><div class="line">2012-03</div><div class="line">2012-04-day1</div><div class="line">2012-04-day2</div><div class="line">2012-04-day3</div><div class="line">======</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># more +3 log2012.log </span></div><div class="line">2012-03</div><div class="line">2012-04-day1</div><div class="line">2012-04-day2</div><div class="line">2012-04-day3</div><div class="line">======</div><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例2：从文件中查找第一个出现”day3”字符串的行，并从该处前两行开始显示输出"><a href="#实例2：从文件中查找第一个出现”day3”字符串的行，并从该处前两行开始显示输出" class="headerlink" title="实例2：从文件中查找第一个出现”day3”字符串的行，并从该处前两行开始显示输出"></a>实例2：从文件中查找第一个出现”day3”字符串的行，并从该处前两行开始显示输出</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">more +/day3 log2012.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># more +/day3 log2012.log </span></div><div class="line">...skipping</div><div class="line">2012-04-day1</div><div class="line">2012-04-day2</div><div class="line">2012-04-day3</div><div class="line">2012-05</div><div class="line">2012-05-day1</div><div class="line">======[root@localhost <span class="built_in">test</span>]<span class="comment">#</span></div></pre></td></tr></table></figure>
<h3 id="实例3：设定每屏显示行数"><a href="#实例3：设定每屏显示行数" class="headerlink" title="实例3：设定每屏显示行数"></a>实例3：设定每屏显示行数</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">more -5 log2012.log</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment"># more -5 log2012.log </span></div><div class="line">2012-01</div><div class="line">2012-02</div><div class="line">2012-03</div><div class="line">2012-04-day1</div><div class="line">2012-04-day2</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;最下面显示了该屏展示的内容占文件总行数的比例，按 Ctrl+F 或者 空格键 将会显示下一屏5条内容，百分比也会跟着变化。      </p>
<h3 id="实例4：列一个目录下的文件，由于内容太多，我们应该学会用more来分页显示。这得和管道-结合起来"><a href="#实例4：列一个目录下的文件，由于内容太多，我们应该学会用more来分页显示。这得和管道-结合起来" class="headerlink" title="实例4：列一个目录下的文件，由于内容太多，我们应该学会用more来分页显示。这得和管道 | 结合起来"></a>实例4：列一个目录下的文件，由于内容太多，我们应该学会用more来分页显示。这得和管道 | 结合起来</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>命令：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ls -l  | more -5</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>输出：</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">[root@localhost <span class="built_in">test</span>]<span class="comment">#  ls -l  | more -5</span></div><div class="line">总计 36</div><div class="line">-rw-r--r-- 1 root root  308 11-01 16:49 log2012.log</div><div class="line">-rw-r--r-- 1 root root   33 10-28 16:54 log2013.log</div><div class="line">-rw-r--r-- 1 root root  127 10-28 16:51 log2014.log</div><div class="line">lrwxrwxrwx 1 root root    7 10-28 15:18 log_link.log -&gt; log.log</div><div class="line">-rw-r--r-- 1 root root   25 10-28 17:02 log.log</div><div class="line">-rw-r--r-- 1 root root   37 10-28 17:07 log.txt</div><div class="line">drwxr-xr-x 6 root root 4096 10-27 01:58 scf</div><div class="line">drwxrwxrwx 2 root root 4096 10-28 14:47 test3</div><div class="line">drwxrwxrwx 2 root root 4096 10-28 14:47 test4</div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<strong>说明：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;每页显示5个文件信息，按 Ctrl+F 或者 空格键 将会显示下5条文件信息。</p>

	

	
		<span class="different-posts"><a href="/2017/10/12/2. Linux 命令/12. Linux 命令- more/" onclick="window.history.go(-1); return false;">⬅️ Go back </a></span>

	

</article>

	</main>

	<footer class="footer">
	<div class="footer-content">
		
	      <div class="footer__element">
	<p>Hi there, <br />welcome to my Blog glad you found it. Have a look around, will you?</p>
</div>

	    
	      <div class="footer__element">
	<h5>Check out</h5>
	<ul class="footer-links">
		<li class="footer-links__link"><a href="/archives">Archive</a></li>
		
		  <li class="footer-links__link"><a href="/atom.xml">RSS</a></li>
	    
		<li class="footer-links__link"><a href="/about">about page</a></li>
		<li class="footer-links__link"><a href="/tags">Tags</a></li>
		<li class="footer-links__link"><a href="/categories">Categories</a></li>
	</ul>
</div>

	    

		<div class="footer-credit">
			<span>© 2017 失落的乐章 | Powered by <a href="https://hexo.io/">Hexo</a> | Theme <a href="https://github.com/HoverBaum/meilidu-hexo">MeiliDu</a></span>
		</div>

	</div>


</footer>



</body>

</html>
